package geppetto.main;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.io.PrintStream;

public class PuntuationBasedClassifier {
	protected static String source;
	protected static String output;

	public static void main(String[] args) throws Exception{

		source = args[0];
		output = args[1];

		BufferedReader sourceReader = new BufferedReader(new InputStreamReader(new FileInputStream(source), "UTF-8"));
		PrintStream outputWriter = new PrintStream(new File(output), "UTF-8");
		
		while(sourceReader.ready()){			
			String line = sourceReader.readLine();
			String[] words = line.split("\\s+");
			String[] tags = new String[words.length];
			String lastTag = "NULL";
			for(int i = words.length - 1; i >= 0; i--){
				if(words[i].equals(".")){
					lastTag = "D";
				}
				if(words[i].equals("?")){
					lastTag = "I";
				}
				if(words[i].equals("!")){
					lastTag = "E";
				}
				tags[i] = lastTag;
			}
			for(String tag : tags){
				outputWriter.print(tag + " ");
			}
			outputWriter.println();
		}

	}
}
